//
//  PushViewCOntroller.m
//  06-UINavigationController
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "PushViewCOntroller.h"

@interface PushViewCOntroller ()

@end

@implementation PushViewCOntroller

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:0.966 green:1.000 blue:0.429 alpha:1.000];
    UIButton *button =[UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor blueColor];
    button.frame = CGRectMake(0, 0, 200, 200);
    [button addTarget:self action:@selector(backButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}
- (void)backButton:(UIButton *)button {
    // pop (出栈)当前ViewController出栈
    // 回到上一级视图控制器
    NSLog(@"%@", self.navigationController.viewControllers);
    [self.navigationController popToRootViewControllerAnimated:YES];
    // 回到根视图控制器
    [self.navigationController popViewControllerAnimated:YES];
    // 返回指定的视图控制器(在栈里面指定)
//    self.navigationController popToViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
